package cn.com.code.hwjs;

import java.util.Scanner;

/**
 * 蛇形矩阵
 * https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e?tpId=37&tqId=21258&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
 *
 * @author zhengpei
 * @date 2022/5/25
 */
public class Hwjs35 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
      int n = sc.nextInt();

      // 建立数组 n 行
      int[][] result = new int[n][];
      int t = 1;
      for (int i = 0; i < n; i++) {
        result[i] = new int[n - i];
        for (int j = 0; j < i + 1; j++) {
          result[i - j][j] = t;
          t++;
        }
      }

      for (int[] a : result) {
        for (int a1 : a) {
          System.out.print(a1 + " ");
        }
        System.out.println();
      }

    }
  }


}
